package org.example.day20240905.view;

import org.example.day20240905.dao.UserDao;
import org.example.day20240905.model.User;
import org.example.day20240905.util.GlobalInput;

import java.util.Scanner;
import java.util.UUID;

public class UserView {
    public boolean registerUser(){
        User user = new User();
        Scanner scanner = GlobalInput.getScanner();
        System.out.println("请输入email：");
        String email = scanner.nextLine();
        user.setEmail(email);
        System.out.println("请输入用户名：");
        String userName = scanner.nextLine();
        user.setUserName(userName);
        System.out.println("请输入密码：");
        String passWord = scanner.nextLine();
        user.setPassWorld(passWord);
        UUID uuid = UUID.randomUUID();
        user.setId(uuid.toString());
        UserDao userDao = new UserDao();

        if(userDao.registerUser(user)){
            return true;
        }else {
            return false;
        }
    }
}
